# @Time : 2021/5/29 17:17
# @Author : Li Kunlun
# @Description : pytorch测试

import torch

# 创建一个5*3的随机矩阵
x = torch.rand(5, 3)
print(x)
y = torch.ones(5, 3)
print(y)

# 矩阵相加
print(x + y)

# Tensor在GPU上运算
print("----------------------------------")
if torch.cuda.is_available():
    # 将x或者y装载到GPU中进行操作
    x = x.cuda()
    y = y.cuda()
    print(x + y)


if __name__=="__main__":
    print("run")